import Mock from 'mockjs';
import sitManageJson from '../../data/system/sitManage.json';

export default {
    className: "sys.model.sit",
    queryData: function(postData) {
        return Mock.mock({
            isSuccess: "Y",
            reason: "",
            message: [],
            "data": {
                "recordCount": 4,
                "pageCount": 1,
                "pageIndex": 1,
                "pageSize": 20,
                "queryResult": sitManageJson
            }
        });
    },
    queryByKeyID: function(postData) {
        var curFindObject = null;
        for (var i = 0; i < sitManageJson.length; i++) {
            if (postData.keyID == sitManageJson[i].keyID) {
                curFindObject = sitManageJson[i];
                break;
            }
        }
        if (curFindObject == null) {
            return Mock.mock({
                isSuccess: "Y",
                reason: "",
                message: [],
                "data": {
                "keyID|1000-9999": 1000,
                "sitCode": /^[a-z][a-z][a-z][a-z][a-z]$/,
                "sitName": Mock.mock('@ctitle'),
                "operator": Mock.mock('@ctitle'),
                "sitStatus": "启用",
                "lastUpdatedBy": Mock.mock('@ctitle'),
                "lastUpdateTime": Mock.mock('@now'),
                "isEnabledVal": "Enable"
                }
            });
        }else {
            return {
                isSuccess: "Y",
                reason: "",
                message: [],
                data: curFindObject,
            };
        }
    },
};
